#include "cworld.h"

cworld::cworld(){
	train=NULL;
	player=NULL;
}

void cworld::draw(){
	update_cam(player->carts[0]->x,player->carts[0]->y,player->carts[0]->rot);
	grass.draw();
	train->draw();
	player->draw();
}

void cworld::update(){
	
	if (train==NULL)
		train= new ctrain(3);

	if (player==NULL)
		player= new cplayer();

	while (train->addrail());

	train->update();
	player->update();

	FOR(i,train->wagons.size())
		player->collide(*train->wagons[i]);

	FOR(i,train->obstacles.size())
		player->collide(train->obstacles[i]);
}
